<template>
  <div class="list-detail">
    <div style="width:220px;height:220px;;margin:13px auto">
      <router-link :to="linkto">
        <img :src="data.thumb" style="width:100%;height:100%;object-fit:cover;" />
      </router-link>
    </div>
    <div style="margin-left:15px">
      <div style="width:100%;height:30px;line-height:30px">
        <span class="sale-money" style="font-size:16px">￥{{data.money_sell | toFixed(2)}}</span>
        <span v-if="$store.getters.orgId!=1&&data.market_price>=data.money_sell" style="text-decoration:line-through;color:#bbb">￥{{data.market_price | toFixed(2)}}</span>
      </div>
      <div class="goods-name" style="margin:5px 0;text-overflow: ellipsis;overflow: hidden;white-space: nowrap;width: 90%;">
        <router-link :to="linkto"> {{data.name}} </router-link>
      </div>
      <div style="width:100%;height:5%;overflow:hidden;text-overflow:ellipsis;white-space: nowrap;margin:5px 0;font-size:12px;">
        {{data.gift_id}}{{data.no_obsolete?'/'+data.no_obsolete:''}}{{data.gb_code?'/'+data.gb_code:''}}
      </div>
      <div style="width:100%;height:5%;margin:5px 0;font-size:12px;">
        {{data.type_name}}
        <span style="padding-left:5px">{{data.texture == 'null' ? '' : data.texture}}</span>
        <span style="padding-left:5px">{{data.product_size}}</span>
        <span style="padding-left:5px;font-size:12px;">{{data.box_num&&data.box_num>0?data.box_num+'个/箱':''}}</span>
      </div>
      <div v-if="data.is_ticket_convertible == 1 || data.is_integral_convertible == 1" title="会员票数/非会员票数" style="width:100%;height:5%;margin:5px 0;font-size:12px;">兑换票数：{{data.ticket_value_vip || 0}}/{{data.ticket_value || 0}}</div>
      <div v-if="from==1" style="width:100%;height:5%;margin:5px 0;font-size:12px;">
        {{data.from_name}}{{data.docking_nick?'/'+data.docking_nick:''}}</div>
      <div v-if="from==2" style="width:100%;height:5%;margin:5px 0;font-size:12px;">
        剩余库存：{{data.num}}</div>
      <div style="width:100%;height:5%;margin:5px 0;font-size:12px;position:relative">
        上架时间：{{data.on_sale_time.substring(0,10)}}
        <el-button type="primary" size="mini" @click="add_click" style="position:absolute;top:-10px;right:10px">+购物车
        </el-button>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "DjGiftCard",
  props: {
    data: {
      type: Object,
      default() {
        return {};
      }
      // box_num: "0"
      // from_name: "富阳仓"
      // gb_code: null
      // gift_describe: null
      // gift_id: "7736"
      // gift_unit: "1"
      // img: "http://img.hahaipi.com/quetu.png"
      // in_car: 0
      // market_price: "0.0000"
      // money_sell: "0.0000"
      // name: "13寸拔鼠团子"
      // no_obsolete: "0102991307"
      // num: "99"
      // on_sale_time: "2018/02/27"
      // product_size: ""
      // ratio: 100
      // texture: null
      // thumb: "http://img.hahaipi.com/quetu.png"
      // type_id: "523"
      // type_name: "其他"
    },
    from: {
      type: Number,
      default: 0
      // 1：供应商，2：中央仓
    },
    usedfor: {
      type: Number,
      default: 0
      // 1:运管系统采购下单，2：采购平台总部下单，3：采购平台总部统配
    },
    linkto:{
      type:Object,
      default:null
      // 点击图片或名称的跳转地址
    }
  },
  created() {
  },
  methods: {
    // 点击添加礼品
    add_click() {
      this.$emit("addclick", this.data);
    }
  }
};
</script>
<style scoped>
.list-detail {
  width: 260px;
  height: 400px;
  float: left;
  margin: 0 16px 16px 0;
  border: 1px solid #ccc;
  font-size: 12px;
  color: #888;
  background: #fff;
}
.list-detail:hover {
  box-shadow: 4px 4px 3px #dddddd;
  border: 2px solid #3396fc;
}
.list-detail .sale-money {
  font-size: 14px;
  padding-right: 20px;
  font-weight: bold;
  color: #000;
}
.list-detail .goods-name {
  font-size: 14px;
  width: 100%;
  height: 5%;
  color: #000;
}
</style>